package com.lcf.error;

import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@ControllerAdvice
public class ErrorHandler {

    @ResponseBody
    @ExceptionHandler(Exception.class)
    public Map<String, Object> errorResultMap(Exception ex) {
        Map<String, Object> result = new HashMap<>();
        ex.printStackTrace();
        result.put("errCode", 500);
        result.put("errMsg", ex.getMessage());
        return result;
    }
}
